home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr50 / wbb13.zip / SAMPLEB3.BAS < prev    next >
BASIC Source File  |  1993-06-04  |  4KB  |  267 lines

  1.  
  2.  
  3. rem
  4. rem Dumb terminal program
  5. rem
  6. rem This is a fairly complete example of using buttons in DOS and Windows
  7. rem
  8.  
  9.  
  10.   rem
  11.   rem is there mouse
  12.   rem
  13.   mouseflag=mouseon
  14.  
  15.  
  16.   rem
  17.   REM
  18.   REM LAYOUT SCREEN
  19.   REM
  20.   CLS
  21.  
  22.   rem
  23.   rem make red bar at top
  24.   rem
  25.   color 7,4
  26.   locate 1,1
  27.   print space$(80);
  28.   locate 2,1
  29.   print space$(80);
  30.   locate 3,1
  31.   print space$(80);
  32.  
  33.   if mouseflag<>0 then
  34.  
  35.     rem
  36.     rem make my push buttons
  37.     rem
  38.     CBUTTON "Exit",1068,0,"Push",0,1,1,8,3,7,1
  39.     CBUTTON "Hangup",1059,0,"Push",0,71,1,10,3,7,1
  40.  
  41.     rem
  42.     rem make and turn on correct radio buttons
  43.     rem
  44.     cbutton " Full Duplex",1060,0,"Radio",0,12,1,13,1,7,4
  45.     cbutton " Half Duplex",1061,0,"Radio",0,12,2,13,1,7,4
  46.     Radioon 1061
  47.     cbutton " 8 data bits",1062,0,"Radio",0,27,1,13,1,7,4
  48.     cbutton " 7 data bits",1063,0,"Radio",0,27,2,13,1,7,4
  49.     Radioon 1062
  50.     cbutton " 2400 baud",1064,0,"Radio",0,42,1,12,1,7,4
  51.     cbutton " 1200 baud",1065,0,"Radio",0,42,2,12,1,7,4
  52.     cbutton " 300 baud",1066,0,"Radio",0,42,3,12,1,7,4
  53.     Radioon 1065
  54.  
  55.   else
  56.  
  57.     rem
  58.     rem make my push buttons
  59.     rem
  60.     CBUTTON "F10-Exit",1068,0,"Push",0,1,1,10,3,7,4
  61.     CBUTTON "F1-Hangup",1059,0,"Push",0,68,1,13,3,7,4
  62.  
  63.     rem
  64.     rem make and turn on correct radio buttons
  65.     rem
  66.     cbutton " F2-Full",1060,0,"Radio",0,12,1,13,1,7,4
  67.     cbutton " F3-Half",1061,0,"Radio",0,12,3,13,1,7,4
  68.     Radioon 1061
  69.     cbutton " F4-8 data",1062,0,"Radio",0,27,1,13,1,7,4
  70.     cbutton " F5-7 data",1063,0,"Radio",0,27,2,13,1,7,4
  71.     Radioon 1062
  72.     cbutton " F6-2400",1064,0,"Radio",0,42,1,12,1,7,4
  73.     cbutton " F7-1200",1065,0,"Radio",0,42,2,12,1,7,4
  74.     cbutton " F8-300",1066,0,"Radio",0,42,3,12,1,7,4
  75.     Radioon 1065
  76.   end if
  77.  
  78.   rem
  79.   rem default states
  80.   rem
  81.   fullhalf=1061
  82.   bits$="8,"
  83.   parity$="N,"
  84.   speed$="1200,"
  85.   stop$="1,"
  86.  
  87.   rem
  88.   rem define scrollable area (so it doesn't scroll buttons)
  89.   rem
  90.   scrollarea 1,4,80,25
  91.   color 7,0
  92.   locate 4,1
  93.  
  94.  
  95.   rem
  96.   rem open communications port
  97.   rem
  98.    open "com2:"+speed$+parity$+bits$+stop$ for random as #1 len=2048
  99.  
  100.    rem
  101.    rem misc.
  102.    rem
  103.    lf$=chr$(10)
  104.  
  105. 100
  106.  
  107. rem
  108. rem get input from communications port
  109. rem
  110. rem
  111. rem Strip out LF characters
  112. rem
  113.  
  114.   t = LOC(1)
  115.   IF t > 0 THEN
  116.     a$=input$(t,1)
  117.     if len(a$)>0 then
  118. nocr:
  119.       if lastchar$=chr$(13)
  120.         l=len(a$)
  121.         t=instr(a$,lf$)
  122.         if t>0 then
  123.          if l>1 then
  124.           a$=left$(a$,t-1)+right$(a$,l-t)
  125.           goto nocr
  126.          else
  127.           goto 100
  128.          end if
  129.         end if
  130.      end if
  131.      PRINT a$;
  132.      lastchar$=a$
  133.     ELSE
  134.  
  135.       rem come here if some kind of comm error
  136.     end if
  137.  
  138.  
  139.   END IF
  140.  
  141.  
  142.  
  143. rem
  144. rem get input from keyboard
  145. rem
  146.  
  147.   b$ = INKEY$
  148.  
  149.  
  150.   IF b$ <> "" THEN
  151.  
  152.     rem
  153.     rem look for function keys
  154.     rem
  155.  
  156.     if len(b$)>1 then
  157.  
  158.       if asc(right$(b$,1))=68 then
  159.  
  160.     rem
  161.     rem F10 exit
  162.     rem
  163.     close #1
  164.     stop
  165.  
  166.       elseif asc(right$(b$,1))=59 then
  167.  
  168.     rem
  169.     rem F1- Hangup
  170.     rem
  171.     beep             :rem positive sign button was pushed
  172.     print #1,"+++";
  173.     for t=0 to 4000
  174.     next t
  175.     print #1,"ATH";chr$(13);
  176.  
  177.       elseif asc(right$(b$,1))=60 then
  178.     rem
  179.     rem make full duplex
  180.     rem
  181.     fullhalf=0
  182.     Radiooff 1061
  183.     Radioon 1060
  184.  
  185.       elseif asc(right$(b$,1))=61 then
  186.     rem
  187.     rem make half duplex
  188.     rem
  189.     fullhalf=1
  190.     Radiooff 1060
  191.     Radioon 1061
  192.  
  193.       elseif asc(right$(b$,1))=62 then
  194.     rem
  195.     rem make 8 data bits
  196.     rem
  197.     bits$="8,"
  198.     parity$="N,"
  199.     stop$="1,"
  200.     Radiooff 1063
  201.     Radioon 1062
  202.     setcom 1,","+parity$+bits$+stop$
  203.  
  204.       elseif asc(right$(b$,1))=63 then
  205.     rem
  206.     rem make 7 data bits
  207.     rem
  208.     bits$="7,"
  209.     Parity$="E,"
  210.     stop$="1,"
  211.     Radiooff 1062
  212.     Radioon 1063
  213.     setcom 1,","+parity$+bits$+stop$
  214.  
  215.       elseif asc(right$(b$,1))=64 then
  216.     rem
  217.     rem make 2400 baud
  218.     rem
  219.     speed$="2400,"
  220.     Radiooff 1065
  221.     Radiooff 1066
  222.     Radioon 1064
  223.     setcom 1,speed$
  224.  
  225.       elseif asc(right$(b$,1))=65 then
  226.     rem
  227.     rem make 1200 baud
  228.     rem
  229.     speed$="1200,"
  230.     Radiooff 1064
  231.     Radiooff 1066
  232.     Radioon 1065
  233.     setcom 1,speed$
  234.  
  235.       elseif asc(right$(b$,1))=66 then
  236.     rem
  237.     rem make 300 baud
  238.     rem
  239.     speed$="300,"
  240.     Radiooff 1064
  241.     Radiooff 1065
  242.     Radioon 1066
  243.     setcom 1,speed$
  244.  
  245.  
  246.       end if
  247.  
  248.       goto 100
  249.  
  250.     else
  251.  
  252.       if fullhalf=0 then
  253.     print b$;
  254.       end if
  255.       PRINT #1, b$;
  256.  
  257.     end if
  258.  
  259.   END IF
  260.  
  261.   GOTO 100
  262.  
  263.  
  264.  
  265.  
  266.  
  267.